package com.tang.sys.controller;

import com.tang.sys.ResponseResult;
import com.tang.sys.entity.Article;
import com.tang.sys.service.IArticleService;
import com.tang.sys.service.ICategoryService;
import com.tang.sys.vo.CategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 文章表 前端控制器
 * </p>
 *
 * @author shankaka
 * @since 2023-04-14
 */
@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private IArticleService iArticleService;

    @Autowired
    private ICategoryService iCategoryService;

//    @GetMapping("/list")
//    public List<Article> test(){
//        return iArticleService.list();
//    }

    @GetMapping("/hotArticleList")
    public ResponseResult hotArticleList(){

        ResponseResult result =  iArticleService.hotArticleList();
        return result;
    }

    @GetMapping("/newArticleList")
    public ResponseResult newArticleList(){
        ResponseResult result= iArticleService.newArticleList();
        return result;
    }

    @GetMapping("/articleList")
    public ResponseResult articleList(Integer pageNum,Integer pageSize,Integer categoryId){
        return iArticleService.articleList(pageNum,pageSize,categoryId);
    }

    @PutMapping("updateViewCount/{id}")
    public ResponseResult updateViewCount(@PathVariable("id") Long id){
        return iArticleService.updateViewCount(id);
    }


    @GetMapping("/{id}")
    public ResponseResult getArticleDetail(@PathVariable("id") Long id){
        return iArticleService.getArticleDetail(id);
    }

    @GetMapping("/getTotal")
    public ResponseResult getTotal(){

        return iArticleService.getTotal();
    }




}
